/**
 * jQuery Validation Plugin 1.8.0
 * 
 * http://bassistance.de/jquery-plugins/jquery-plugin-validation/
 * http://docs.jquery.com/Plugins/Validation
 * 
 * Copyright (c) 2006 - 2011 Jörn Zaefferer
 * 
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 */
(function() {
	function a(b) {
		return b.replace(/<.[^<>]*?>/g, " ").replace(/&nbsp;|&#160;/gi, " ")
				.replace(/[0-9.(),;:!?%#$'"_+=\/-]*/g, "");
	}
	jQuery.validator.addMethod("maxWords", function(b, c, d) {
				return this.optional(c) || a(b).match(/\b\w+\b/g).length < d
			}, jQuery.validator.format("Please enter {0} words or less."));
	jQuery.validator.addMethod("minWords", function(b, c, d) {
				return this.optional(c) || a(b).match(/\b\w+\b/g).length >= d
			}, jQuery.validator.format("Please enter at least {0} words."));
	jQuery.validator.addMethod("rangeWords", function(b, c, d) {
				return this.optional(c)
						|| a(b).match(/\b\w+\b/g).length >= d[0]
						&& b.match(/bw+b/g).length < d[1]
			}, jQuery.validator
					.format("Please enter between {0} and {1} words."))
})();
jQuery.validator.addMethod("lettersonly", function(a, b) {
			return this.optional(b) || /^[a-z]+$/i.test(a)
		}, "只允许输入字母");
jQuery.validator.addMethod("nowhitespace", function(a, b) {
			return this.optional(b) || /^\S+$/i.test(a)
		}, "不允许输入空格");
jQuery.validator.addMethod("dateITA", function(a, b) {
			var c = false;
			if (/^\d{1,2}\/\d{1,2}\/\d{4}$/.test(a)) {
				var d = a.split("/");
				c = parseInt(d[0], 10);
				var f = parseInt(d[1], 10);
				d = parseInt(d[2], 10);
				var e = new Date(d, f - 1, c);
				c = e.getFullYear() == d && e.getMonth() == f - 1
						&& e.getDate() == c ? true : false
			} else
				c = false;
			return this.optional(b) || c
		}, "请输入正确的日期");
jQuery.validator.addMethod("dateNL", function(a, b) {
			return this.optional(b)
					|| /^\d\d?[\.\/-]\d\d?[\.\/-]\d\d\d?\d?$/.test(a)
		}, "Vul hier een geldige datum in.");
jQuery.validator.addMethod("time", function(a, b) {
			return this.optional(b)
					|| /^([01][0-9])|(2[0123]):([0-5])([0-9])$/.test(a)
		}, "请输入有效的时间，在00:00到23:59之间");
jQuery.validator.addMethod("phoneUS", function(a, b) {
	a = a.replace(/\s+/g, "");
	return this.optional(b)
			|| a.length > 9
			&& a
					.match(/^(1-?)?(\([2-9]\d{2}\)|[2-9]\d{2})-?[2-9]\d{2}-?\d{4}$/)
}, "请输入有效的电话号码");
jQuery.validator.addMethod("phoneUK", function(a, b) {
	return this.optional(b)
			|| a.length > 9
			&& a
					.match(/^(\(?(0|\+44)[1-9]{1}\d{1,4}?\)?\s?\d{3,4}\s?\d{3,4})$/)
}, "请输入有效的电话号码");
jQuery.validator.addMethod("mobileUK", function(a, b) {
			return this.optional(b) || a.length > 9
					&& a.match(/^((0|\+44)7(5|6|7|8|9){1}\d{2}\s?\d{6})$/)
		}, "Please specify a valid mobile number");
jQuery.validator.addMethod("ipv4", function(a, b) {
	return this.optional(b)
			|| /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/i
					.test(a)
}, "请输入有效的IPv4地址");
jQuery.validator.addMethod("ipv6", function(a, b) {
	return this.optional(b)
			|| /^((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))$/i
					.test(a)
}, "请输入有效的IPv6地址");
jQuery.validator.addMethod("alphanumeric", function(value, element) {
			return this.optional(element) || /^\w+$/i.test(value);
		}, "只允许包含字母、数字、空格或下划线");
jQuery.validator.addMethod("username", function(value, element) {
			return this.optional(element) || /^[\u0391-\uFFE5\w]+$/.test(value);
		}, "只允许包含中文、英文、数字和下划线");
jQuery.validator.addMethod("email", function(value, element) {
			return this.optional(element)
					|| /^[_\.0-9A-Za-z-]+@([0-9A-Za-z][0-9A-Za-z-]+\.)+[A-Za-z]{2,4}$/
							.test(value);
		}, "请输入正确的E-Mail邮箱地址");
jQuery.validator.addMethod("requiredTo", function(value, element, param) {
			var requiredTo = $(param).val();
			if (requiredTo != "") {
				return value != "";
			} else {
				return true;
			}
		}, "此内容为必填项,请输入");
jQuery.validator.addMethod("requiredOne", function(value, element, param) {
			var requiredOne = $(param).val();
			if (requiredOne == "") {
				return value != "";
			} else {
				return true;
			};
		}, $.validator.format("两项必须填写一项"));
jQuery.validator.addMethod("notEqual", function(value, element, param) {
			return value != param;
		}, $.validator.format("输入值不允许为{0}"));
jQuery.validator.addMethod("positive", function(value, element) {
			return this.optional(element) || value > 0;
		}, "只允许输入整数");
jQuery.validator.addMethod("positiveInteger", function(value, element) {
			return this.optional(element) || /^[1-9]\d*$/.test(value);
		}, "只允许输入正整数");
jQuery.validator.addMethod("positiveNumber", function(value, element) {
			return this.optional(element) || /^[1-9]\d*|0$/.test(value);
		}, "只允许输入正整数,包括0");
jQuery.validator.addMethod("imageFile", function(value, element) {
			return this.optional(element)
					|| /(.jpg|.jpeg|.gif|.bmp|.png)$/i.test(value);
		}, "图片文件格式错误");
jQuery.validator.addMethod("excelFile", function(value, element) {
			return this.optional(element) || /(.xls|.xlsx)$/i.test(value);
		}, "Excel文件格式错误");
jQuery.validator.addMethod("mobile", function(value, element) {
			return this.optional(element)
					|| /^(13|14|15|18)[0-9]{9}$/.test(value);
		}, "请输入正确的手机号码,如：15888888888");
jQuery.validator.addMethod("phone", function(value, element) {
			return this.optional(element) || /^0?\d{2,3}\-\d{7,8}$/.test(value);
		}, "请输入正确的联系号码，如：0755-12345678");
jQuery.validator.addMethod("integerValidate", function(value, element) {
			return this.optional(element)
					|| /^(([1-9][0-9]+)|([1-9][0-9]+\.[0-9]{1,2}))$/.test(value);
		}, "请输入正确的数字");
jQuery.validator.addMethod("userNumber", function(value, element) {
			return this.optional(element) || /^\w+$/.test(value);
		}, "由数字、26个英文字母或者下划线组成的字符串");
jQuery.validator.addMethod("isempty", function(a, b) {
			return true;
		}, 'empty error');